package m.fun.model;

import m.common.model.LinkTableMeta;
import m.common.model.MigrationModel;
import m.common.model.Model;
import m.common.model.TableMeta;
import m.common.model.util.ModelQueryList;
import m.common.model.util.QueryCondition;

import java.util.List;
import java.util.stream.Collectors;

@TableMeta(name = "tf_offer_detail", description = "报价单明细")
public class OfferDetail extends Model implements MigrationModel {
    @Override
    public List<String> migrationOidList(String storeOid) throws Exception {
        return ModelQueryList.getModelList(this.getClass(),new String[]{"oid"},null,
                        QueryCondition.eq("offer.store.oid",storeOid))
                .stream().map(Model::getOid).collect(Collectors.toList());
    }
    @LinkTableMeta(name="offer_oid",table= OfferInfo.class,description="所属报价单")
    private OfferInfo offer;
    @LinkTableMeta(name="goods_offer_oid",table= GoodsOffer.class,description="商品报价")
    private GoodsOffer goodsOffer;

    public OfferInfo getOffer() {
        return offer;
    }

    public void setOffer(OfferInfo offer) {
        this.offer = offer;
    }

    public GoodsOffer getGoodsOffer() {
        return goodsOffer;
    }

    public void setGoodsOffer(GoodsOffer goodsOffer) {
        this.goodsOffer = goodsOffer;
    }
}
